//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
/// @file
///
///
/// 
/// @author Davide Pasca
/// 
//==================================================================

#ifndef RENDVERTEXBUFFER_H
#define RENDVERTEXBUFFER_H

#ifdef TARGET_D3D
#include <direct3d.h>
#endif
#include "psys.h"

//==================================================================
///
//==================================================================
class RendVertexBuffer
{
	class RendDevice			*_rdevicep;
	int							_max_verts;
	int							_stride;
	int							_total_alloc_size;
#ifdef TARGET_D3D
	int							_d3d_last_idx;
	com_ptr<D3DVertexBuffer>	_d3d_vbuffp;
#endif

public:
	RendVertexBuffer( class RendDevice *rdevicep, int max_verts, int stride );

#ifdef _DEBUG
	~RendVertexBuffer();
#endif

	void ReallocBuffer( int max_verts, int stride );
	void UploadData( const u_char *src_datap, int from_vert, int n_verts );

#ifdef TARGET_D3D
	D3DVertexBuffer	*GetD3DVBuff() {	return _d3d_vbuffp;	}
#endif
	int				GetStride() const {	return _stride;	}

	friend class RendDevice;
};

#endif
